﻿package tbo.components 
{
	import flash.display.Sprite;
	import flash.text.TextField;
	import tbo.actors.Actor;
	import tbo.components.buttons.MoveBtn;
	import tbo.events.TBOActorEvent;
	import tbo.components.buttons.AttackBtn;
	import flash.events.MouseEvent;
	import com.greensock.TweenLite;
	/**
	 * ...
	 * @author ...
	 */
	public class ActorQuickView extends Sprite
	{
		private var txtName:TextField;
		private var btnAtk:AttackBtn;
		private var btnMove:MoveBtn
		private var act:Actor;
		
		public function ActorQuickView() 
		{
			txtName = new TextField();
			this.addChild(txtName);
			
			btnAtk = new AttackBtn();
			btnAtk.x = 0;
			btnAtk.y =  20;
			btnAtk.addEventListener(MouseEvent.CLICK, onAtkClick);
			this.addChild(btnAtk);
			
			btnMove = new MoveBtn();
			btnMove.x = 0;
			btnMove.y = 10;
			btnMove.addEventListener(MouseEvent.CLICK, startMove);
			this.addChild(btnMove);
		}
		
		public function onAtkClick(e:MouseEvent):void {
			act.targetStart();
		}
		
		public function startMove(e:MouseEvent):void {
			act.moveStart();
			//dispatchEvent(new TBOActorEvent(TBOActorEvent.MOVE_START, act));
		}
		
		public function setActor(a:Actor):void {
			act = a;
			txtName.text = a.gameName;
			this.x = a.x + a.width;
			this.y = a.y;
			TweenLite.to(this, 1, { alpha: 1 } );
			this.addEventListener(MouseEvent.ROLL_OUT, onRout);
		}
		
		public function onRout(e:MouseEvent):void {
			TweenLite.to(this, 1, { alpha: 0 } );
		}
		
		public function setClickedActor(e:TBOActorEvent):void {
			setActor(e.actor);
		}
		
	}
	
}